package com.sumainfor.pc.gmio.controller.secretary;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.service.SeEleMeterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Date 2018年11月7日
 * @Describe 银行
 */
@RestController
@RequestMapping("/secretary/SeEleMeter")
public class SeEleMeterController implements Serializable {
    @Autowired
    private SeEleMeterService seEleMeterService;
    /**
     * 查询水表录入记录的列表
     */
    @PostMapping("/getEleMeterList")
    public JsonResult getRepairList(@RequestBody Map<String,Object>params){
        System.out.println("接收到达参数:"+params);
        return seEleMeterService.getEleMeterList(params);
    }
    /**
     * 新增水表记录
     */
    @PostMapping("/addEleMeter")
    public JsonResult addEleMeter(@RequestBody Map<String,Object>params){
        JsonResult result=new JsonResult();
        int resultsjk=seEleMeterService.addEleMeter(params);
        if (resultsjk>0){
            result.putSuccess("创建成功");
        }else{
            result.putFailed("服务器繁忙");
        }
        return  result;
    }
    /**
     * 查询账单列表
     * @param params
     * @param pager
     * @return
     */
    @GetMapping("/getWegList")
    public JsonResult getWegList(@RequestParam Map<String,Object>params,Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=seEleMeterService.getWegListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>>getCommunityList=seEleMeterService.getWegList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
}
